

<template>

  <div class="addUserInfo">
     <ViewTitle text="录入信息" />
   
   
     <div class="box1">
      <div>
        <span><b class="hongdian">*</b>险种类型:</span>
          <div>
               <el-select v-model="params.insutype" placeholder="结算方式" >
                <el-option
                  v-for="(item,index) in yibao_insutype"
                  :key="'index1'+index"
                  :label="item.name"
                  :value="item.value"

                >
                </el-option>
              </el-select>
        </div>
      </div>
         <div>
        <span><b  class="hongdian">*</b>清算类别:</span>
          <div>
               <el-select v-model="params.clr_type" placeholder="清算类别" >
                <el-option
                  v-for="(item,index) in $baseBai['yibaoInfo']['clr_type']"
                  :key="'index1'+index"
                  :label="item.label"
                  :value="item.value"

                >
                </el-option>
              </el-select>
        </div>
      </div>

       <div>
            <span><b  class="hongdian">*</b>日期:</span>
           <div>
               <el-date-picker
              v-model="params.time"
              type="daterange"
              range-separator="-"
               @change="riqiSel"
                value-format="yyyy-MM-dd"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
            </div>
        </div>
        <div>
        <span><b  class="hongdian">*</b>医疗费总额:</span>
        <el-input
          size="mini"
            type="number"
            placeholder="请输入医疗费总额"
          v-model="params.medfee_sumamt"
       >
        </el-input>
      </div>
       <div>
        <span><b  class="hongdian">*</b>基金支付总额:</span>
        <el-input
          size="mini"
          type="number"
          v-model="params.fund_pay_sumamt"
       >
        </el-input>
      </div>
       <div v-if="thatF.yibao.selectType=='billDetail'">
        <span><b  class="hongdian">*</b>现金支付金额:</span>
        <el-input
          size="mini"
          type="number"
          v-model="params.cash_payamt"
       >
        </el-input>
      </div>
        <div>
        <span><b  class="hongdian">*</b>个人账户支付金额:</span>
        <el-input
          size="mini"
          type="number"
          v-model="params.acct_pay"
       >
        </el-input>
      </div>
        <div>
        <span><b  class="hongdian">*</b>定点医药机构结算笔数:</span>
        <el-input
          size="mini"
          type="number"
          v-model="params.fixmedins_setl_cnt"
       >
        </el-input>
      </div>
      <div>
        <span><b  class="hongdian">*</b>结算经办机构:</span>
        <el-input
          size="mini"
         
          v-model="params.setl_optins"
       >
        </el-input>
      </div>
       <div v-if="thatF.yibao.selectType=='billDetail'">
        <span><b  class="hongdian">*</b>文件上传:</span>
        <div>
            <el-upload
                class="upload-demo"
                action=""
                :multiple="false"
                
                :limit="1"
                name="file"
                :http-request="handleRequest"
                accept=".zip,.rar"
                :on-change="handleChange"
                 
                >
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">请上传Zip压缩包</div>
                </el-upload>
        </div>
      </div>
      </div> 
     
         <ViewTitle text="查询结果" v-if="params.status==2" />
       <div class="box1"  v-if="params.status==2" >
             <div>
                 <span>结算经办机构:</span>
                 <div>
                     {{data.setl_optins}}
                 </div>
             </div>
             <div>
                 <span>对账结果:</span>
                 <div>
                       {{data.stmt_reslt}}
                 </div>
             </div>
             <div>
                 <span>对账结果说明:</span>
                 <div>
                       {{data.stmt_rslt_dscr}}
                 </div>
             </div>

             <div v-if="this.data.path">
                 <span>文件下载:</span>
                 <div>
                       <el-button  class="butB_Add butB_Add2"   @click="xiazai()">点击下载</el-button>
                 </div>
             </div>

             
             
       </div>
    
    <div class="buts">
             <el-button  class="butB_Add butB_Add2"  @click="save(1)">查询</el-button>
        
         <el-button  class="butB_Add butB_Add2"  @click="getClinicSetl(1)">获取金额信息</el-button>
    </div>
  </div>
</template>
<script>
let t;

import ViewTitle from "@/forComponents/viewTitle/index.vue";
import { mapState,mapActions } from "vuex";
export default {
  props: ['thatF'],
  data() {
    return {
      headers:{
        "Authorization":  "Bearer " + localStorage.getItem("token"),
      },
     
        fileList:[],
       
      params:{
       status:1,
        insutype:'', 
       clr_type:'',
       time:'',
       stmt_begndate:'',
       stmt_enddate:'',
       medfee_sumamt:'',
       fund_pay_sumamt:'',
       acct_pay:'',
       fixmedins_setl_cnt:'',
       setl_optins:'',
       cash_payamt:'',
      },
    data:{
//             "setl_optins": "610602",
//             "stmt_rslt_dscr": "凯撒好的撒旦看到",
//             "stmt_rslt": "0"
    },
   
    };
  },
  
  mounted(){
    t=this;

      console.log()
    
  },
 
  methods: {
    xiazai(){
        
      window.open(this.data.path)
    },
    handleRequest(param){
      console.log("param",param)
    },
       handleChange(file, fileList) {
        this.fileList = fileList.slice(-3);
        console.log("this.fileList ",this.fileList )
      },
      riqiSel(e){
             let time=(this.params.time.toString()).split(',');
            this.params.stmt_begndate=time[0]
            this.params.stmt_enddate=time[1]
       },
       getClinicSetl(){
         var d={
          insutype:t.params.insutype,
          stmt_begndate: this.params.stmt_begndate,
          stmt_enddate:this.params.stmt_enddate
         }
         if(t.params.clr_type==21){
           
            t['_API']['getYbCashSearch'](d).then(res=>{
                            if(res.code==200){
                              t.params.setl_optins=res.data.setl_optins
                              t.params.medfee_sumamt=res.data.medfee_sumamt
                              t.params.fund_pay_sumamt=res.data.fund_pay_sumamt
                               t.params.acct_pay=res.data.acct_pay
                               t.params.fixmedins_setl_cnt=res.data.fixmedins_setl_cnt
                                      }
                        })
         }else{
             t['_API']['getClinicSetl'](d).then(res=>{
                            if(res.code==200){
                              t.params.setl_optins=res.data.setl_optins
                              t.params.medfee_sumamt=res.data.medfee_sumamt
                              t.params.fund_pay_sumamt=res.data.fund_pay_sumamt
                               t.params.acct_pay=res.data.acct_pay
                               t.params.fixmedins_setl_cnt=res.data.fixmedins_setl_cnt
                                      }
                        })
         }
         

           
       },
    save(num){
 

                  if(t.thatF.yibao.selectType=='bill'){
                    
                       let d={
                            insutype:t.params.insutype, 
                            clr_type:t.params.clr_type, 
                            stmt_begndate:t.params.stmt_begndate, 
                            stmt_enddate:t.params.stmt_enddate, 
                            medfee_sumamt:t.params.medfee_sumamt, 
                            fund_pay_sumamt:t.params.fund_pay_sumamt, 
                            acct_pay:t.params.acct_pay, 
                            fixmedins_setl_cnt:t.params.fixmedins_setl_cnt, 
                            setl_optins:t.params.setl_optins,
                        
                        }
                       
                       
                      // for (const key in d) {
                      //       if(!d[key]){
                      //           return t.$message.error("您还有未输入的填项")
                      //       }
                      // }
                      
                        t['_API']['getclinic_ybCheckSettlement'](d).then(res=>{
                            if(res.code==200){
                                t.params.status=2;       
                              t.data=res.data;
                                      }
                        })
                  }else if(t.thatF.yibao.selectType=='billDetail'){


                       let d={
                            insutype:t.params.insutype, 
                            clr_type:t.params.clr_type, 
                            stmt_begndate:t.params.stmt_begndate, 
                            stmt_enddate:t.params.stmt_enddate, 
                            medfee_sumamt:t.params.medfee_sumamt, 
                            fund_pay_sumamt:t.params.fund_pay_sumamt, 
                            acct_pay:t.params.acct_pay, 
                            fixmedins_setl_cnt:t.params.fixmedins_setl_cnt, 
                        
                        }


                          let fileObj = this.fileList[0].raw;
                         let form = new FormData();
                         
                            form.append('insutype', t.params.insutype)
                            form.append('clr_type', t.params.clr_type)
                            form.append('stmt_begndate', t.params.stmt_begndate)
                            form.append('stmt_enddate', t.params.stmt_enddate)
                            form.append('medfee_sumamt', t.params.medfee_sumamt)
                            form.append('fund_pay_sumamt', t.params.fund_pay_sumamt)
                            form.append('acct_pay', t.params.acct_pay)
                            form.append('fixmedins_setl_cnt', t.params.fixmedins_setl_cnt)
                            form.append('cash_payamt', t.params.cash_payamt)
                             form.append('setl_optins', t.params.setl_optins)
                            
                            form.append("file", fileObj);
                         t['_API']['getclinic_ybCheckDetailSettlement'](form).then(res=>{
                            if(res.code==200){
                                t.params.status=2;       
                              t.data=res.data;
                                      }
                        })
                      
                  }
               

            

              //   let d={
              //        insutype:t.params.insutype, 
              //       clr_type:t.params.clr_type, 
              //       stmt_begndate:t.params.stmt_begndate, 
              //       stmt_enddate:t.params.stmt_enddate, 
              //       medfee_sumamt:t.params.medfee_sumamt, 
              //       fund_pay_sumamt:t.params.fund_pay_sumamt, 
              //       acct_pay:t.params.acct_pay, 
              //       fixmedins_setl_cnt:t.params.fixmedins_setl_cnt, 
                 
              //   }
              //   if(t.thatF.yibao.selectType=='billDetail'){
              //       d.cash_payamt=t.params.cash_payamt;
              //   }
              //    console.log(d)
              //  for (const key in d) {
              //       if(!d[key]){
              //           return t.$message.error("您还有未输入的填项")
              //       }
              //  }
               
              //   t['_API'][url](d).then(res=>{
              //       if(res.code==200){
              //           t.params.status=2;       
              //          t.data=res.data;
              //                 }
              //   })
           

            
    },
  

    
    
  },
    computed: {
    ...mapState({
         yibao_insutype:state => state.dictBai.yibao_insutype,
       //  yibao_med_type:state => state.dictBai.yibao_med_type,
         
    }),
  },
  components: {
    ViewTitle,
    //  FormInfo
  },
};
</script>
<style lang='scss' scoped>
.addUserInfo {
  padding: 0 4%;
  .box1 {
    display: flex;
    flex-wrap: wrap;
    padding: 20px 0;
    > div {
      position: relative;
      width: 33%;
      display: flex;
      align-items: center;
      // justify-content: center;
      margin-bottom: 20px;

      > span {
        display: inline-block;
        width: 100px;
        margin-right: 10px;
        // >b{color: red;margin-right: 5px;}
      }
      /deep/ .el-input {
        width: 200px;
      }
    }
  }
  .box3 {
    margin: 20px 0;
  }

  .dukaBut {
    margin: 0px 0 20px;
  }
}

.buts{
    display: flex;
    align-items: center;
    justify-content: center;
    .butB_Add1{
        

    width: 200px;
    // position: absolute;
    bottom: 28px;
    right: 45px;
    }
      .butB_Add2{
        

    width: 200px;
    // position: absolute;
    bottom: 28px;
    right: 280px;
    }
}


</style>